home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 February / macformat-034.iso / mac / Shareware City / Developers / appe Windows 2.03 / 'jGNE' resource.c next >
Encoding:
C/C++ Source or Header  |  1995-06-14  |  1.7 KB  |  69 lines  |  [TEXT/CWIE]

  1. // File "jgnefilter.c" -
  2.  
  3. // Should the Inline jGNEFilter use MW's FRALLOC macros?
  4. #define ____USE_FRALLOC____
  5.  
  6. // ***********************************************************************************
  7. // Function Prototype
  8.  
  9. asm void main(void);
  10.  
  11. // ***********************************************************************************
  12. // ***********************************************************************************
  13.  
  14. asm void main() {
  15.     bra.s    Continue
  16.         
  17. Next_Filter:
  18.     dc.l    0                        // Saved Address of Next jGNEFilter in the chain.
  19.                                     //   We jump directly to it, no JSR's or RTS's.
  20. Event_Helper:
  21.     dc.l    0                        // Pointer to Helper function in our application.
  22.                                     //   We clear it to NIL when we quit as a flag
  23. Event_Helper_Data:
  24.     dc.l    0                        // Promised storage for the Helper function, 
  25.                                     //   which can modify the pointer dynamically.
  26. Continue:
  27.  
  28. // FRALLOC is a MW macro that simplifies ASM local vars and
  29. //   stack maintenance -- use it if we got it, its very easy
  30. #ifdef ____USE_FRALLOC____
  31.     fralloc
  32. #else
  33.     link    a6, #0
  34. #endif ____USE_FRALLOC____
  35.  
  36.     // Save the Volatile registers for safety
  37.     movem.l    d0-d2/a0-a2, -(a7)            
  38.  
  39.     // Load the Helper from Inline Storage and test it. If Helper is NIL,
  40.     //   then our handler was released -- and we just jump to the next Filter
  41.     move.l    Event_Helper, a0
  42.     move.l    a0, d0
  43.     tst.l    d0                            
  44.     beq        End_Filter
  45.     
  46.     // Straight C Calling Conventions, call the Helper function
  47.     move.l    Event_Helper_Data, -(a7)
  48.     move.l    a1, -(a7)
  49.     move.l    Event_Helper, a0
  50.     jsr        (a0)
  51.     add.l    #8, a7
  52.         
  53. End_Filter:
  54.  
  55.     // Clean up the same way we got here
  56.     movem.l    (a7)+, d0-d2/a0-a2
  57.  
  58. #ifdef ____USE_FRALLOC____
  59.     frfree
  60. #else
  61.     unlk    a6
  62. #endif ____USE_FRALLOC____
  63.     
  64.     // Jump to the next filter in the chain
  65.     move.l    Next_Filter, a0
  66.     jmp        (a0)
  67.     }
  68.  
  69.